package b2.scene.base
{
	import b2.scene.*;
	import b2.util.*;
	import b2.widget.*;
	import b2.widget.rank.*;
	import b2.widget.task.*;
	import b2.widget.tech.*;
	import b2.widget.warehouse.*;
	
	import flash.events.*;
	import flash.filters.*;
	import flash.text.*;

	public class BaseDepartment extends BasicButton
	{
		private const nameStrs:Array = ["交易站", "科技炉", "军部大厅", "我的仓库", "荣誉堂"];
		private var index:int;
		
		public function BaseDepartment(DepartImage:Class, index:int)
		{
			super(DepartImage);
			this.index = index;
			var nameText:TextField = new TextField();
			nameText.selectable = false;
        	nameText.autoSize = TextFieldAutoSize.CENTER;
			nameText.defaultTextFormat = new TextFormat("微软雅黑", 18, 0xFFFF00, true);
			nameText.filters = [new GlowFilter(0x000000, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			nameText.text = nameStrs[index];
			nameText.x = 130;
			nameText.y = 35;
			addChild(nameText);
			this.addEventListener(MouseEvent.CLICK, onMouseClick);
		}
		
		private function onMouseClick(event:MouseEvent):void
		{
			if (index == 0)
			{
				var popMessage:PopMessage = new PopMessage("交易站尚未开启！", 0xFF0000);
				WidgetManager.getInstance().popOut([popMessage], false, true);
			}
			else if (index == 1)
			{
				BottomBar.onTechIconClick(event);
			}
			else if (index == 2)
			{
				BottomBar.onTaskIconClick(event);
			}
			else if (index == 3)
			{
				BottomBar.onWarehouseIconClick(event);
			}
			else if (index == 4)
			{
				BottomBar.onHonourIconClick(event);
			}
		}
	}
}